package com.woniuxy.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * @Author: 马宇航
 * @Todo: 正式开发的写法，以及后期springboot中的开发的写法！
 * @DateTime: 22/01/24/0024 下午 2:48
 * @Component: 成都蜗牛学苑
 **/
//和@Service一样，把这个类注册到spring中
@Controller
@RequestMapping("/managerController")
public class MySecondController {
//    当你的url /findOne的时候，就会进入到这个方法中
    @RequestMapping(path = {"/findOne","/findTwo"},method = RequestMethod.GET )
//    @GetMapping("/findOne")//这个注解和上一个注解一样的效果
    public ModelAndView findOne(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg","欢迎来到对抗路！");
        modelAndView.setViewName("myTest");//跳转到/WEB-INF/jsp/myTest.jsp
        return modelAndView;
    }
//    findAll前面得有一层 /asdf/findAll123
    @RequestMapping("/*/findAll*")
    public ModelAndView findAll(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg","lol！");
        modelAndView.setViewName("myTest");
        return modelAndView;
    }
    //  /asdf/123123/sdfsadffindAll 这个请求也能找到我的这个方法 /**/ 这个表示任意层数
    @RequestMapping("/**/*findAll")
    public ModelAndView findAllAll(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg","lol！");
        modelAndView.setViewName("myTest");
        return modelAndView;
    }
}
